package ua.vn.ticket_scanner.utils;

import android.content.Context;
import android.os.Vibrator;

import ua.vn.ticket_scanner.TApplication;

/**
 * Created by Ivan on 26.06.13.
 */
public class VibratorHelper {

    private static final int LONG = 800;
    private static final int SHORT = 400;

    private static final int ONCE = -1;
    private static final int REPEAT = 2;

    private static final long[] VIBRATOR_PATTERN = { SHORT, 500, SHORT, 500 };

    private static Vibrator getVibrator() {
        return (Vibrator) TApplication.getInstance().getSystemService(Context.VIBRATOR_SERVICE);
    }

    public static void longVibro() {
        getVibrator().vibrate(LONG);
    }

    public static void shortVibro() {
        getVibrator().vibrate(SHORT);
    }

    public static void doubleShortVibro() {
        getVibrator().vibrate(VIBRATOR_PATTERN, ONCE);
    }

    public static void repeatShortVibro() {
        getVibrator().vibrate(VIBRATOR_PATTERN, REPEAT);
    }

    public static void cancelVibro() {
        getVibrator().cancel();
    }
}
